View Javadoc
1 package jrre.unittests; 2 3 public class Simple { 4 5 public Simple(){ 6 7 //jrre.api.java.lang.System.out.println("Fib(10) = "); 8 //jrre.api.java.lang.System.out.println(fib(10)); 9 } 10 11 public static void main(String [] srgs){ 12 13 /* 14 int addResult = add(2, 4); 15 int subResult = sub(4, 1); 16 int mulResult = mul(4, 2); 17 int divResult = div(4, 2); 18 System.out.println(6); 19 int result = fact(5); 20 int fibResult = s.fib(10); 21 */ 22 23 Simple s = new Simple(); 24 25 jrre.api.java.lang.System.out.println("Fib(10) = "); 26 jrre.api.java.lang.System.out.println(s.fib(10)); 27 } 28 29 public int fact(int number){ 30 31 if(number == 1) 32 return 1; 33 else 34 return(number * fact(number-1)); 35 } 36 37 public int fib(int number){ 38 39 if(number <= 0) 40 return 0; 41 if(number <= 2) 42 return 1; 43 else 44 return fib(number-1) + fib(number-2); 45 } 46 47 public int add(int a, int b) { 48 return a + b; 49 } 50 51 public int sub(int a, int b) { 52 return a - b; 53 } 54 55 public int mul(int a, int b) { 56 return a * b; 57 } 58 59 public int div(int a, int b) { 60 return a / b; 61 } 62 63 }

This page was automatically generated by Maven